1. Field of the Invention
The present invention relates to an image processing apparatus and a method, and an imaging apparatus, and more particularly to an image processing apparatus and a method for processing an image by using a face detection result, and an imaging apparatus.
2. Description of the Related Art
An operation of a conventional white balance gain calculation circuit used for a digital camera will be described. First, as illustrated in FIG. 8, an imaging area is divided into a predetermined number of blocks (m blocks) of a plurality of pixels. For each of the blocks (1 to m), pixel values are added and averaged for each color to calculate color average values (R[i], G[i], B[i]). Then, for example, by using the following equation (1), color evaluation values (Cx[i], Cy[i]) are calculated:Cx[i]=(R[i]−B[i])/Y[i]×1024 Cy[i]=(R[i]+B[i])−2G[i]/Y[i]×1024  (1)Y[i]=R[i]+2G[i]+B[i], where [i] is an index number of each of the blocks.
A white object is captured under various light sources beforehand to calculate color evaluation values. Accordingly, if a white detection range 301 illustrated in FIG. 9 includes a color evaluation value calculated for each block, this block is determined to be white. Then, pixel values of blocks determined to be white are integrated. The white detection range 301 is obtained by plotting the calculated color evaluation values based on the white object captured beforehand under various light sources. In FIG. 9, a negative direction of x coordinate (Cx) indicates a color evaluation value when a white of a high color temperature object is captured, and a positive direction indicates a color evaluation value when a white of a low color-temperature object is captured. In the figure, y coordinate (Cy) indicates a green component ratio of the light source. A G component increases toward the negative direction, indicating that the light source is a fluorescent lamp.
Then, based on the integrated pixel values (sumR, sumG, sumB), white balance coefficients (WBCo_R, WBCo_G, WBCo_B) are calculated by using the following equation (2):WBCo_R=sumY×1024/sumRWBCo_G=sumY×1024/sumG  (2)WBCo_B=sumY×1024/sumBwhere sumY=(sumR+2×sumG+sumB)/4.
However, the conventional white balance coefficient calculation method has the following problems. Under a light source such as sunlight, white color evaluation values are distributed around an area A in FIG. 9, and flesh (skin) colors are distributed around an area B. Flesh color evaluation values under the sunlight are distributed in an area almost similar to that of white color evaluation values under a low color light source. Thus, if there is a little white part in an imaging area, and a picture of a person is taken in close-up as illustrated in FIG. 10, color evaluation values in the imaging area are distributed in the area B in FIG. 9. Consequently, a flesh color is erroneously determined to be white under a low color temperature, and the human flesh is corrected to be white. Also, when chromatic colors distributed around a color area that indicates a human flesh are scattered all over the imaging area, the chromatic colors are erroneously determined to be white, and the flesh is corrected to be white.
The above-described problems have conventionally been dealt with by determining a light source to be external light when an object illuminance is high, and the white detection range is narrowed to prevent the flesh color from being erroneously determined to be white.
Generally, fluorescent lamps include a variety of light sources, such as a source where whites are distributed around an area C, and a light source where whites are distributed below the area C. The white detection range has to be expanded to deal with such light sources. However, under high color temperature fluorescent lamps of low illuminance or middle color temperature fluorescent lamps, flesh colors may be distributed around a portion (area C) below a blackbody locus. Thus, expansion of the white detection range causes erroneous determination of the flesh color, resulting in a whitened flesh color.
U.S. Pat. No. 6,975,759 discusses a method of detecting a face, extracting a flesh color of the face when the face is detected, comparing the extracted flesh color with a reference flesh color, and correcting white balance based on the comparison result.
However, this conventional white balance correction value calculation method makes no consideration about a case where a face detection circuit erroneously detects a face. Consequently, even when the face detection circuit erroneously detects a false face area, the false face area may be corrected to be an appropriate flesh color. Thus, a desired white balance correction value cannot be acquired.
Depending on performance of an imaging apparatus regarding a processing speed, face detection may be unavailable during shooting. In such an imaging apparatus. even if a face is detected at a shooting preparation stage, the position of an object may be shifted during shooting. Such a case has not been taken into consideration. In other words, even if a face is correctly detected during a shooting preparation period, white balance correction accuracy may be lowered in the end. FIG. 11 illustrates an example where face detection is executed before a first switch SW1 is turned on, and the position of an object is shifted immediately before turning-on of a second switch SW2 (switch for actual shooting). Use of the face detection result obtained immediately before turning-on of the first switch SW1 makes it difficult to acquire a correct face color evaluation value when the second switch SW2 is turned on (at the time of actual shooting), thus resulting in lowering white balance correction accuracy.